import QtQuick 2.0


Rectangle {
    id:root
    property int fontsize: 20
    property  int maxwindow_h: 100
    property  int maxwindow_w: 100
    property  int window_x: 0
    property  int window_y: 0
    property  bool pass: false
    property Item rp: root
    property bool focu: false
    property string txt: ""
    signal enter(string txt)
    width: 50
    height: 100
    Component.onCompleted: {
        console.debug("aa");
        aa.forceActiveFocus();
    }
    Rectangle{
        anchors.fill: parent
        border.color: "black"
        TextInput {
      //      validator: IntValidator{
            id: textInput1;
            text: txt
            anchors.fill: parent
            font.family: "Courier"
            font.bold: true
            horizontalAlignment: Text.AlignHCenter
            font.pointSize: root.fontsize
            focus: root.focu
            verticalAlignment: Text.AlignVCenter
            activeFocusOnPress: false

            MouseArea{
                id:aa
                anchors.fill: parent
                onClicked: {
                    parent.forceActiveFocus();
                    //parent.openSoftwareInputPanel();
                }

            }
        }
    }
    property string valeKey : ""
    property string pasKey : ""
    Keyboard{
        window_x:root.window_x
        window_y:root.window_y
        id:key
        rows: 3
        columns: 11
        max_h: maxwindow_h
        max_w: maxwindow_w
        state: textInput1.focus? "":"Hid"
        //  anchors.top:textInput1.bottom
        onLetterClicked: {
            if(letter=="Enter"){
                //key.state="Hid"
                enter(valeKey)
            }else if(letter=="Hiden"){
             //   key.state="Hid"
                  enter(valeKey)
            }else if(letter=="<"){
                root.valeKey=root.valeKey.substring(0,root.valeKey.length-1)
                root.pasKey=root.pasKey.substring(0,root.pasKey.length-1)
            }else{
                root.pasKey=root.pasKey+"*"
                root.valeKey=root.valeKey+letter
            }
            if(pass)
                textInput1.text = root.pasKey
            else
                textInput1.text = root.valeKey
        }
        keys:"qwertyuiop< asdfghjkl]> zxcvbnm "

    }

}
